/* GUI CONVERTED from msmsiq.p (converter v1.76) Tue Oct 16 13:16:29 2001 */
/* msmsiq.p - MPS SUMMARY INQUIRY                                       */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.6.1.3 $                                            */

/*V8:ConvertMode=Report                                        */
/* REVISION: 1.0    LAST MODIFIED: 07/17/86     BY: EMB       */
/* REVISION: 1.0    LAST MODIFIED: 09/12/86     BY: EMB *20*  */
/* REVISION: 2.0    LAST MODIFIED: 03/06/87     BY: EMB *A39* */
/* REVISION: 4.0    LAST MODIFIED: 12/30/87     BY: WUG *4.0* */
/* REVISION: 4.0    LAST MODIFIED: 01/08/88     BY: EMB *A133**/
/* REVISION: 2.0    LAST MODIFIED: 01/06/88     BY: PML *A125**/
/* REVISION: 4.0    LAST MODIFIED: 12/30/87     BY: WUG *A137**/
/* REVISION: 2.0    LAST MODIFIED: 01/20/88     BY: PML *A158**/
/* REVISION: 4.0    LAST MODIFIED: 03/21/88     BY: EMB *A162**/
/* REVISION: 5.0    LAST MODIFIED: 12/20/88     BY: EMB *B005**/
/* REVISION: 5.0    LAST MODIFIED: 01/27/89     BY: EMB *A615**/
/* REVISION: 5.0    LAST MODIFIED: 11/08/89     BY: EMB *B386**/
/* REVISION: 5.0    LAST MODIFIED: 02/14/90     BY: EMB *B568**/
/* REVISION: 6.0    LAST MODIFIED: 05/18/90     BY: RAM *D026**/
/* REVISION: 6.0    LAST MODIFIED: 07/23/90     BY: emb *D040**/
/* REVISION: 6.0    LAST MODIFIED: 08/16/90     BY: emb *D057**/
/* REVISION: 6.0    LAST MODIFIED: 05/07/91     BY: emb *D618**/
/* REVISION: 7.0    LAST MODIFIED: 10/10/91     BY: emb *F024**/
/* REVISION: 7.0    LAST MODIFIED: 09/01/94     BY: ljm *FQ67**/
/* REVISION: 8.6    LAST MODIFIED: 10/13/97     BY: ays *K0XF**/

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/13/00 BY: *N0KR* myb              */
/* Old ECO marker removed, but no ECO header exists *F0PN*               */
/* $Revision: 1.6.1.3 $    BY: Russ Witt   DATE: 09/21/01 ECO: *P01H*      */

/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE msmsiq_p_1 "End!Date"
/* MaxLen: Comment: */

&SCOPED-DEFINE msmsiq_p_2 "Bucket"
/* MaxLen: Comment: */

&SCOPED-DEFINE msmsiq_p_3 "Start!Date"
/* MaxLen: Comment: */

&SCOPED-DEFINE msmsiq_p_4 "Neg!ATP"
/* MaxLen: Comment: */

&SCOPED-DEFINE msmsiq_p_5 "Per/!Bkt"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define new shared variable frwrd like soc_fcst_fwd.
define new shared variable bck like soc_fcst_bck.
define new shared variable fcsduedate as date.

define variable week as integer.

define new shared variable start as date  column-label "Start!Date".
define new shared variable ending as date column-label "End!Date".
define variable old_start as date.
define new shared variable part like mrp_part.
define new shared variable site like in_site.
define new shared variable dwm as character format "!(1)" label "Bucket".
define new shared variable idays as integer format ">>9"
                                          column-label "Per/!Bkt".
define new shared variable dsp-neg-atp as logical initial no
                                          column-label "Neg!ATP".
define new shared variable reserved-inventory like in_qty_oh.
define new shared variable atp-sales-order      like sod_nbr.
define new shared variable atp-sales-order-line like sod_line.
define new shared variable path1 like prd_path.

find first soc_ctrl no-lock no-error.

if available soc_ctrl then do:

   frwrd = soc_fcst_fwd.
   bck = soc_fcst_bck.
end.

find first mrpc_ctrl no-lock no-error.
start = today.
{wbrp01.i}
if mrpc_sum_def <> 0 then
   repeat:
   if weekday(start) = mrpc_sum_def then leave.
   start = start - 1.
end.

part = global_part.
site = global_site.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/  part
   site
   start ending dwm idays
   dsp-neg-atp
with frame a no-underline width 80 attr-space THREE-D /*GUI*/.

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

repeat:
   do on error undo, retry:
      if start = ? then start = today.
      if old_start <> ? then start = old_start.
      if dwm = "" then dwm = "W".
      if idays = 0 or idays = ? then idays = 1.

      if c-application-mode <> 'web' then
      update part
         site
         start
         ending
         dwm
         idays
         dsp-neg-atp
      with frame a
      editing:

         if frame-field = "part" then do:
            /* FIND NEXT/PREVIOUS RECORD */
            {mfnp.i pt_mstr part pt_part part pt_part pt_part}
            if recno <> ? then do:
               part = pt_part.
               display part with frame a.
            end.
         end.
         else if frame-field = "site" then do:

            /* FIND NEXT/PREVIOUS RECORD */
            {mfnp.i si_mstr site si_site site si_site si_site}

            if recno <> ? then display si_site @ site with frame a.

         end.
         else do:
            status input.
            readkey.
            apply lastkey.
         end.
      end.

      {wbrp06.i &command = update &fields = "  part  site start ending dwm idays" &frm = "a"}

      if (c-application-mode <> 'web') or
         (c-application-mode = 'web' and
         (c-web-request begins 'data')) then do:

         find pt_mstr no-lock where pt_part = part no-error.
         if not available pt_mstr then do with frame a:
            {pxmsg.i &MSGNUM=16 &ERRORLEVEL=3}
         /* ITEM NUMBER DOES NOT EXIST */

            if c-application-mode = 'web' then return.
            else next-prompt part.
            undo, retry.
         end.

         find si_mstr no-lock where si_site = site no-error.
         if not available si_mstr then do with frame a:
            {pxmsg.i &MSGNUM=708 &ERRORLEVEL=3}
            /* SITE DOES NOT EXIST */

            if c-application-mode = 'web' then return.
            else next-prompt site.
            undo, retry.
         end.

         if index("dwmp",dwm) = 0 then do with frame a:
            {pxmsg.i &MSGNUM=14 &ERRORLEVEL=3}
            /* INTERVAL MUST BE (D)ay (W)eek OR (M)onth.  Please re-enter. */

            if c-application-mode = 'web' then return.
            else next-prompt dwm.
            undo, retry.
         end.

/*       DO NOT ALLOW UNKNOWN VALUES (QUESTION MARK) */
         if dsp-neg-atp = ? then do:
            /* Unknown value (question mark) is not allowed */
            {mfmsg.i 1235 3}
            if c-application-mode = 'web':u then return.
            next-prompt dsp-neg-atp with frame a.
            undo, retry.
         end.

         if start = ? then start = today.

      end.
      /* SELECT OUTPUT DEVICE */
      /* OUTPUT DESTINATION SELECTION */
      {gpselout.i &printType = "terminal"
                  &printWidth = 80
                  &pagedFlag = " "
                  &stream = " "
                  &appendToFile = " "
                  &streamedOutputToTerminal = " "
                  &withBatchOption = "no"
                  &displayStatementType = 1
                  &withCancelMessage = "yes"
                  &pageBottomMargin = 6
                  &withEmail = "yes"
                  &withWinprint = "yes"
                  &defineVariables = "yes"}

      hide message no-pause.
   end.

   hide frame a.

   old_start = start.
   path1 = path.

   {gprun.i ""hkmsmsiqa.p""}

   {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


end.
global_part = part.

{wbrp04.i &frame-spec = a}
